import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/home/Home.vue";
import GoodsList from "../views/good/goodslist.vue";
import GoodsDetails from "../views/good/goodsdetails.vue";
import ShowCart from "../views/cart/showcart.vue";
import OrderFirst from "../views/order/orderfirst.vue";
import OrderSecond from "../views/order/ordersecond.vue";
import OrderThree from "../views/order/orderthree.vue";
// import Sider from '../common/sider.vue'
import OrderDetails from "../views/user/orderdetails.vue";
import User from "../views/user/user.vue";
import MyInfo from "../views/user/myinfo.vue";
import MyAddress from "../views/user/myaddress.vue";
import Login from "../views/login/login.vue";
import Index from "../views/index.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Index",
    component: Index,
    redirect: "/home",
    children: [
      {
        path: "/home",
        name: "Home",
        component: Home,
      },
      {
        path: "/goodslist",
        name: "GoodsList",
        component: GoodsList,
      },
      {
        path: "/goodsdetails",
        name: "GoodsDetails",
        component: GoodsDetails,
      },
      {
        path: "/showcart",
        name: "ShowCart",
        component: ShowCart,
      },
      {
        path: "/orderfirst",
        name: "OrderFirst",
        component: OrderFirst,
      },
      {
        path: "/ordersecond",
        name: "OrderSecond",
        component: OrderSecond,
      },
      {
        path: "/orderthree",
        name: "OrderThree",
        component: OrderThree,
      },
      {
        path: "/user",
        name: "User",
        component: User,
        redirect: "/user/orderdetails",
        children: [
          {
            path: "/user/myinfo",
            component: MyInfo,
          },
          {
            path: "/user/orderdetails",
            component: OrderDetails,
          },
          {
            path: "/user/myaddress",
            component: MyAddress,
          },
        ],
      },
    ],
  },
  {
    path: "/login",
    name: Login,
    component: Login,
  },
];

const router = new VueRouter({
  routes,
  scrollBehavior(to, from, savedPosition) {
    return { x: 0, y: 0 };
  },
});

export default router;
